import heapq

# 初始化一个最小堆
heap = [(10, 'f'), (1, 'b'), (3, 'd')]
heapq.heapify(heap)  # 确保列表具有堆的性质

# 新的元素
new_item = (11, 'a')

# 使用 heapreplace 替换堆顶元素
popped_item = heapq.heapreplace(heap, new_item)

print("Popped item:", popped_item)
print("Updated heap:", heap)
